package com.xiaoniu.forum.web.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xiaoniu.forum.entity.TabbarEntity;
import com.xiaoniu.forum.service.TabbarService;
import com.xiaoniu.forum.common.utils.PageUtils;
import com.xiaoniu.forum.common.utils.R;



/**
 * 标签，网页底部展示的标签，都是从该表查出来的

如：首页 、发现 、社区、我的等等
 *
 * @author xiaoniu
 * @email 55333@qq.com
 * @date 2021-03-18 09:10:36
 */
@RestController
@RequestMapping("forum/tabbar")
@Api("tabbar管理")
public class TabbarController {
    @Autowired
    private TabbarService tabbarService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation("查看列表")
    //@RequiresPermissions("forum:tabbar:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tabbarService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ApiOperation("根据ID查看")
    //@RequiresPermissions("forum:tabbar:info")
    public R info(@PathVariable("id") String id){
		TabbarEntity tabbar = tabbarService.getById(id);

        return R.ok().put("tabbar", tabbar);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ApiOperation("保存数据")
    //@RequiresPermissions("forum:tabbar:save")
    public R save(@RequestBody TabbarEntity tabbar){
		tabbarService.save(tabbar);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ApiOperation("修改数据")
    //@RequiresPermissions("forum:tabbar:update")
    public R update(@RequestBody TabbarEntity tabbar){
		tabbarService.updateById(tabbar);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ApiOperation("批量删除")
    //@RequiresPermissions("forum:tabbar:delete")
    public R delete(@RequestBody String[] ids){
		tabbarService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
